package cn.iocoder.an.module.business.dal.mysql.storemanage;

import java.util.*;

import cn.iocoder.an.framework.common.pojo.PageResult;
import cn.iocoder.an.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.an.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.an.module.business.dal.dataobject.storemanage.StoreManageDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.an.module.business.controller.admin.storemanage.vo.*;
import org.apache.ibatis.annotations.Select;

/**
 * 出入库管理 Mapper
 *
 * @author zzy
 */
@Mapper
public interface StoreManageMapper extends BaseMapperX<StoreManageDO> {

    default PageResult<StoreManageDO> selectPage(StoreManagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StoreManageDO>()
                .likeIfPresent(StoreManageDO::getCustomerAccount, reqVO.getCustomerAccount())
                .eqIfPresent(StoreManageDO::getDrawingNumber, reqVO.getDrawingNumber())
                .likeIfPresent(StoreManageDO::getProductName, reqVO.getProductName())
                .betweenIfPresent(StoreManageDO::getOperDate, reqVO.getCreateTime())
                .orderByDesc(StoreManageDO::getOperDate));
    }


//    @Select("SELECT sum(in_amount)  FROM business_store_manage where deleted = '0' and customer_account = #{customerAccount} and drawing_number = #{drawingNumber}")
    public Long selectInCount(StoreManagePageReqVO reqVO);

//    @Select("SELECT sum(out_amount)  FROM business_store_manage where deleted = '0' and customer_account = #{customerAccount} and drawing_number = #{drawingNumber}")
    public Long selectOutCount(StoreManagePageReqVO reqVO);

}